package com.lovo.homework7_14ATM;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class MenuPanel extends JPanel implements ActionListener {
    private JButton jButton1;
    private JButton jButton2;
    private JButton jButton3;
    private JButton jButton4;
    private JButton jButton5;
    private JButton jButton6;


    private Icon buttonIcon1 =util.Util.getIcon("/images/buttonSave.jpg");
    private Icon buttonIcon2 =util.Util.getIcon("/images/buttonGet.jpg");
    private Icon buttonIcon3 =util.Util.getIcon("/images/buttonFind.jpg");
    private Icon buttonIcon4 =util.Util.getIcon("/images/buttonOff.jpg");
    private Icon buttonIcon5 =util.Util.getIcon("/images/buttonModify.jpg");
    private Icon buttonIcon6 =util.Util.getIcon("/images/buttonTansfer.png");

    private ATMmain atMmain;

    public MenuPanel(ATMmain atMmain){
        this.atMmain=atMmain;
        this.setLayout(null);

        this.setOpaque(false);

        jButton1=new JButton(buttonIcon1);
        jButton1.setBounds(884,180,140,50);
        this.add(jButton1);
        jButton1.addActionListener(this);

        jButton2=new JButton(buttonIcon2);
        jButton2.setBounds(884,270,140,50);
        this.add(jButton2);
        jButton2.addActionListener(this);

        jButton3=new JButton(buttonIcon3);
        jButton3.setBounds(884,360,140,50);
        this.add(jButton3);
        jButton3.addActionListener(this);

        jButton4=new JButton(buttonIcon4);
        jButton4.setBounds(0,360,140,50);
        this.add(jButton4);
        jButton4.addActionListener(this);

        jButton5=new JButton(buttonIcon5);
        jButton5.setBounds(0,270,140,50);
        this.add(jButton5);
        jButton5.addActionListener(this);

        jButton6=new JButton(buttonIcon6);
        jButton6.setBounds(0,180,145,46);
        this.add(jButton6);
        jButton6.addActionListener(this);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getSource()==jButton1){
           atMmain.switchPanel("depositPanel");
        }else if (e.getSource()==jButton2){
            atMmain.switchPanel("withDrawPanel");
        }else if (e.getSource()==jButton3){
            //atMmain.getjLabelQuery().setText(atMmain.getUserList);

            atMmain.balance();



            atMmain.switchPanel("queryPanel");
        }else if (e.getSource()==jButton4){
            atMmain.switchPanel("loginPanel");
        }else if (e.getSource()==jButton5){//改密
            atMmain.switchPanel("modifyPanel");
        }else if (e.getSource()==jButton6){//转账
            atMmain.switchPanel("transferPanel");
        }
    }

}
